* Added 'PageRenderingHash' hook for changing the parser cache hash key
authorBrion Vibber <brion@users.mediawiki.org>
Sun, 25 Dec 2005 11:04:40 +0000 (11:04 +0000)
committerBrion Vibber <brion@users.mediawiki.org>
Sun, 25 Dec 2005 11:04:40 +0000 (11:04 +0000)
  from an extension that changes rendering based on nonstandard options.

RELEASE-NOTES
docs/hooks.txt
includes/User.php

index 6d6d0ca..29f4d0a 100644 (file)
@@ -352,6 +352,8 @@ fully support the editing toolbar, but was found to be too confusing.
 * (bug 4377) "[" is not valid in URLs
 * Don't delete thumbnails when refreshing exif metadata. This caused thumbs
   to vanish mysteriously from time to time for files that didn't have metadata.
+* Added 'PageRenderingHash' hook for changing the parser cache hash key
+  from an extension that changes rendering based on nonstandard options.
 
 
 === Caveats ===
index 8ebddc8..85c479c 100644 (file)
@@ -317,6 +317,11 @@ $typeText: array of strings
 'LogPageLogHeader': strings used by wfMsg as a header.
 $headerText: array of strings
 
+'PageRenderingHash': alter the parser cache option hash key
+  A parser extension which depends on user options should install
+  this hook and append its values to the key.
+$hash: reference to a hash key string which can be modified
+
 'TitleMoveComplete': after moving an article (title)
 $old: old title
 $nt: new title
index 07a11b3..c09d0bb 100644 (file)
@@ -1462,6 +1462,19 @@ class User {
 
        }
 
+       /**
+        * Generate a string which will be different for any combination of
+        * user options which would produce different parser output.
+        * This will be used as part of the hash key for the parser cache,
+        * so users will the same options can share the same cached data
+        * safely.
+        *
+        * Extensions which require it should install 'PageRenderingHash' hook,
+        * which will give them a chance to modify this key based on their own
+        * settings.
+        *
+        * @return string
+        */
        function getPageRenderingHash() {
                global $wgContLang;
                if( $this->mHash ){
@@ -1480,9 +1493,13 @@ class User {
                // add in language specific options, if any
                $extra = $wgContLang->getExtraHashOptions();
                $confstr .= $extra;
+               
+               // Give a chance for extensions to modify the hash, if they have
+               // extra options or other effects on the parser cache.
+               wfRunHooks( 'PageRenderingHash', array( &$confstr ) );
 
                $this->mHash = $confstr;
-               return $confstr ;
+               return $confstr;
        }
 
        function isAllowedToCreateAccount() {